<?xml version="1.0"?>
<component name="org.nuxeo.ecm.platform.rendition.search.contentviews.contrib.override">

  <require>org.nuxeo.ecm.platform.rendition.search.contentviews.contrib</require>

  <extension point="contentViews" target="org.nuxeo.ecm.platform.ui.web.ContentViewService">

    <contentView name="stored_rendition_search">

      <title>label.search.results</title>
      <translateTitle>true</translateTitle>

      <emptySentence>label.content.empty.search</emptySentence>
      <translateEmptySentence>true</translateEmptySentence>

      <coreQueryPageProvider>
        <property name="coreSession">#{documentManager}</property>
        <whereClause docType="StoredRenditionSearch">

          <predicate operator="FULLTEXT" parameter="ecm:fulltext_all">
            <field name="ecm_fulltext" schema="stored_rendition_search"/>
          </predicate>

          <predicate operator="FULLTEXT" parameter="dc:title">
            <field name="dc_title" schema="stored_rendition_search"/>
          </predicate>

          <predicate operator="BETWEEN" parameter="dc:created">
            <field name="dc_created_min" schema="stored_rendition_search"/>
            <field name="dc_created_max" schema="stored_rendition_search"/>
          </predicate>

          <predicate operator="BETWEEN" parameter="rend:sourceModificationDate">
            <field name="rend_sourceModification_min" schema="stored_rendition_search"/>
            <field name="rend_sourceModification_max" schema="stored_rendition_search"/>
          </predicate>

          <predicate operator="IN" parameter="rend:renditionName">
            <field name="rend_renditionName" schema="stored_rendition_search"/>
          </predicate>

          <predicate operator="FULLTEXT" parameter="rend:renditionVariant">
            <field name="rend_renditionVariant" schema="stored_rendition_search"/>
          </predicate>

          <fixedPart>
            ecm:mixinType = 'Rendition' AND
            ecm:isProxy = 0 AND
            ecm:isVersion = 0 AND
            SORTED_COLUMN IS NOT NULL
          </fixedPart>
        </whereClause>
        <sort ascending="true" column="dc:title"/>
        <pageSize>20</pageSize>
      </coreQueryPageProvider>

      <searchLayout filterDisplayType="quick" name="stored_rendition_search"/>

      <showFilterForm>true</showFilterForm>
      <showPageSizeSelector>true</showPageSizeSelector>
      <useGlobalPageSize>true</useGlobalPageSize>
      <refresh>
        <event>documentChanged</event>
        <event>documentChildrenChanged</event>
      </refresh>
      <cacheKey>only_one_cache</cacheKey>
      <cacheSize>1</cacheSize>

      <resultLayouts>
        <layout iconPath="/icons/document_listing_icon.png" name="renditions_listing" showCSVExport="true" showEditColumns="true" showSpreadsheet="true" title="document_listing" translateTitle="true"/>
      </resultLayouts>

      <selectionList>CURRENT_SELECTION</selectionList>
      <actions category="CURRENT_SELECTION_LIST"/>

      <resultColumns>
        #{searchDocument.cvd.selectedLayoutColumns}
      </resultColumns>
      <resultLayout>
        #{searchDocument.cvd.resultLayoutName}
      </resultLayout>
      <flags>
        <flag>SEARCH</flag>
      </flags>

    </contentView>

  </extension>

</component>
